package replSet;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import mongoDB.UserModel;

/**
 * 
 * @Title: TestMongoSpiringReslSet.java
 * @Package replSet
 * @Description: 这个是spring与副本集集成
 * @author 刘伟 15818570028@163.com
 * @date 2017年2月20日 下午1:29:49
 * @version V1.0
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring-mongodb-replSet2.xml" })
public class TestMongoSpiringReslSet2 {

	@Autowired
	private MongoTemplate mt;

	@Test
	public void test1() {
		final String COL_NAME = "tuser1";

		// add
		UserModel um = new UserModel();
		um.setAge(12222);
		um.setName("n1");
		um.setUserId("u2242");
		System.out.println(System.currentTimeMillis());
		mt.insert(um, COL_NAME);
		System.out.println(System.currentTimeMillis());

	}

}
